﻿using System.Collections;

namespace TK
{
    public partial class CustomSerializer
    {
        void writeBitArray(CustomSerializerState state, BitArray o) {
            var objID = state.writeHeader();

            var b = new byte[o.Length/8 + (o.Length%8 > 0 ? 1 : 0)];
            o.CopyTo(b, 0);

            state.writeInt32(b.Length);
            state.stm.Write(b, 0, b.Length);

            state.updateHeader(objID);
        }

        object readBitArray(CustomSerializerState state)
        {
            var header = state.readHeader();
            var b = new byte[state.readInt32()];
            state.stm.Read(b, 0, b.Length);
            return new BitArray(b);
        }
    }
}